package com.netease.nie.controllers;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.netease.nie.base.controllers.BaseController;
import com.netease.nie.dto.BannerDto;
import com.netease.nie.facade.BannerFacade;

/**
 * banner接口
 * @author wwbn3695
 * @createDate June 21st,2016
 *
 */
@RestController
@RequestMapping("/api/banner")
public class BannerController extends BaseController {

	@Autowired
	private BannerFacade bannerFacade;
	
	@RequestMapping(value = "/list", method = RequestMethod.GET, produces = "application/json")
	public String list(HttpServletRequest request, int position) throws Exception {
		Long userId = (Long) request.getAttribute("userId");
		List<BannerDto> bannerDtos = bannerFacade.listBannerDtoByPosition(userId, position);
		return jsonSuccess(bannerDtos);
	}
	
}
